﻿using System;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebGui {

    /// <summary>
    /// The code-behind class of the MasterSite
    /// </summary>
    public partial class MasterSite : MasterPage {

        /// <summary>
        /// This method is called when a page is loaded
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        protected void Page_Load(object sender, EventArgs e) {
            if(!Request.IsAuthenticated)
                Menu.Visible = false;
        }

        /// <summary>
        /// The eventhandler for click events in the menu
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        protected void OnMenuItemClick(object sender, MenuEventArgs e) {
            if(e.Item.Text.ToLower().Equals("log af")) {
                Session["user"] = null;
                FormsAuthentication.SignOut();
                FormsAuthentication.RedirectToLoginPage();
            }
        }
    }
}